<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>天天生鲜-用户中心</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/reset1.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/main1.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css">
    <script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
</head>
<body>
<div class="header_con">
    <div class="header">
        <div class="welcome fl">欢迎来到天天生鲜!</div>
        <div class="fr">
            <div class="login_btn fl">
                <span>欢迎您</span>
                <span>|</span>
                <a href="${pageContext.request.contextPath}/user/touserrecord" name="user_name">${sessionScope.username}</a>
            </div>
            <div class="user_link fl">
                <span>|</span>
                <a href="${pageContext.request.contextPath}/user/touserrecord">用户中心</a>
                <span>|</span>
                <a href="cart.html">我的购物车</a>
                <span>|</span>
                <a href="${pageContext.request.contextPath}/order/OrderList?user_id=${user_id}">我的订单</a>
            </div>
        </div>
    </div>
</div>

<div class="search_bar clearfix">
    <a href="${pageContext.request.contextPath}/main/index" class="logo fl"><img src="../images/logo.png"></a>
    <div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
    <form action="${pageContext.request.contextPath}/product/search" method="post" class="search_con fl">
        <input type="text" class="input_text fl" name="name" placeholder="显示全部商品">
        <input type="submit" class="input_btn fr" value="搜索">
    </form>
</div>

<div class="main_con clearfix">
    <div class="left_menu_con clearfix">
        <h3>用户中心</h3>
        <ul>
            <li><a href="user_center_info.jsp">· 个人信息</a></li>
            <li><a href="${pageContext.request.contextPath}/order/OrderList?user_id=${user_id}" target="_blank">· 全部订单</a></li>
            <li><a href="user_center_site.jsp">· 收货地址</a></li>
            <li><a href="user_center_record.jsp" class="active">· 浏览记录</a> </li>
        </ul>
    </div>
    <div class="right_content clearfix">
        <h3 class="common_title2">最近浏览</h3>
        <div class="has_view_list">
            <!--查询条件-->
            <form action="${pageContext.request.contextPath}/user/getRecordAll" method="post" id="find">
                <input type="hidden" name="pageNum" value="${page.pageNum}" id="pageNum">
                <input type="hidden" name="pageSize" value="${page.pageSize}" id="pageSize">
                商品关键字：<input type="text" id="name" name="name" value="${record.name}" />
<%--                    <tr><td>浏览日期：</td><td><input type="date" id="record_date" name="record_date" value="${record_date}" /></td></tr>--%>

                <input type="submit" value="查询">
            </form>

            <ul class="goods_type_list clearfix">
                <c:forEach items="${page.list}" var="re">
                    <li>
                        <a href="${pageContext.request.contextPath}/product/id?id=${re.product_id}"><img src="${pageContext.request.contextPath}/images/goods/${re.product_id}.png"></a>
                        <h4><a href="${pageContext.request.contextPath}/product/id?id=${re.product_id}">${re.name}</a></h4>
                        <div class="operate">
                            <span class="prize">${re.price}</span>
                            <span class="unit">${re.price}/500g</span>
                            <a href="${pageContext.request.contextPath}/product/addProduct?product_id=${re.product_id}" class="add_goods" title="加入购物车"></a>
                        </div>
                    </li>
                </c:forEach>
            </ul>
        </div>
        <div>
            <nav aria-label="Page navigation" style="text-align: center;">
                <ul class="pagination">
                    <li id="first">
                        <a href="javascript:void(0);">
                            <span aria-hidden="true">首页</span>
                        </a>
                    </li>
                    <li id="prev">
                        <a href="javascript:void(0);" aria-label="Previous">
                            <span aria-hidden="true">上一页</span>
                        </a>
                    </li>
                    <c:forEach items="${page.navigatepageNums}" var="i">
                        <li name="pageNum" <c:if test="$(i==page.pageNum">class="active" </c:if>>
                        <a href="javascript:void(0);">
                           ${i}
                        </a></li>
                    </c:forEach>
                    <li id="next">
                        <a href="javascript:void(0);" aria-label="Next">
                            <span aria-hidden="true">下一页</span>
                        </a>
                    </li>
                    <li id="last">
                        <a href="javascript:void(0);" aria-label="Last">
                            <span aria-hidden="true">末页</span>
                        </a>
                    </li>
                    <br />
                    <span style="font-size: 10px;margin-left: 5px;"style="display: block">
                        共${page.total}记录,共${page.pages}页，每页展示${page.pageSize}条记录
                    </span>
                </ul>
            </nav>
        </div>
                <script>
                var pageNum=${page.pageNum};
                var pages=${page.pages};
                var hasPreviousPage=${page.hasPreviousPage};
                var hasNextPage=${page.hasNextPage};
                if(!hasPreviousPage){
                    $("#prev").addClass("disabled");
                    $("#first").addClass("disabled");
                }
                if(!hasNextPage){
                    $("#next").addClass("disabled");
                    $("#last").addClass("disabled");
                }
                $("#first").click(function(){
                   if(!$("#first").hasClass("disabled")){
                       $("#pageNum").val(1);
                       $("#find").submit();
                   }
                });
                $("#prev").click(function(){
                    if(!$("#prev").hasClass("disabled")){
                        $("#pageNum").val(pageNum-1);
                        $("#find").submit();
                    }
                });
                $("#next").click(function(){
                    if(!$("#next").hasClass("disabled")){
                        $("#pageNum").val(pageNum+1);
                        $("#find").submit();
                    }
                });
                $("#last").click(function(){
                    if(!$("#last").hasClass("disabled")){
                        $("#pageNum").val(pages);
                        $("#find").submit();
                    }
                });
                $("li[name='pageNum']").click(function (){
                   if(!$(this).hasClass("active")){
                       $("#pageNum").val($(this).children("a").html());
                       $("#find").submit();
                   }
                });
            </script>
        </div>
</div>



<div class="footer">
    <div class="foot_link">
        <a href="#">关于我们</a>
        <span>|</span>
        <a href="#">联系我们</a>
        <span>|</span>
        <a href="#">招聘人才</a>
        <span>|</span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
    <p>电话：010-****888    京ICP备*******8号</p>
</div>

</body>
</html>
